package com.building.hcrm.base;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

public class BaseAsyncTask<C, C1, C2> extends AsyncTask<C, C1, C2>
{
	protected Context _context;
	protected ProgressDialog _pd;
	private String _msg="数据请求...";
	
	public BaseAsyncTask(Context context)
	{
		_context = context;
	}
	
	public BaseAsyncTask(Context context,String strMsg)
	{
		_context = context;
		if(null != strMsg && 0<strMsg.length())
			_msg = strMsg;
	}
	
	@Override
	protected void onPreExecute()
	{
		super.onPreExecute();
		_pd = new ProgressDialog(_context);
		_pd.setMessage(_msg);
		_pd.setIndeterminate(false);
		_pd.setCancelable(false);
		_pd.show();
	}
	
	@Override
	protected C2 doInBackground(C... params)
	{
		return null;
	}
	
	@Override
	protected void onProgressUpdate(C1... values)
	{
		super.onProgressUpdate(values);
		if (null != _pd && _pd.isShowing())
			_pd.cancel();
	}
	
	@Override
	protected void onPostExecute(C2 result)
	{
		super.onPostExecute(result);
		if (null != _pd && _pd.isShowing())
			_pd.cancel();
	}	
}
